import java.util.Arrays;
import java.util.Comparator;

class Students implements Comparable<Students>{
    public String name;
    public int age;

    public Students(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public int compareTo(Students o) {
        return this.age - o.age;
    }
}
class NameComparator implements Comparator<Students> {

    @Override
    public int compare(Students o1, Students o2) {
        return o1.name.compareTo(o2.name);
    }
}
public class Test3 {
    public static void main(String[] args) {
        Students s1 = new Students("z",17);
        Students s2 = new Students("d",16);
        Students s3 = new Students("b",20);
        Students[] students = {s1,s2,s3};
        NameComparator nameComparator = new NameComparator();
        System.out.println(nameComparator.compare(s1, s2));
        Arrays.sort(students,nameComparator);
    }
    public static void main1(String[] args) {
        Students s1 = new Students("a",17);
        Students s2 = new Students("d",16);
        Students s3 = new Students("b",20);
        Students[] students = {s1,s2,s3};
        Arrays.sort(students);
    }
}
